import React, { PureComponent, createRef } from 'react'

export default class App extends PureComponent {
  constructor() {
    super();

    this.usernameRef = createRef()

    this.state = {
      username: "",
    }
  }

  render() {
    return (
      <div>
        <form onSubmit={e => this.handleSubmit(e)}>
          <label htmlFor="">
            用户： <input id="username" type="text" ref={this.usernameRef}/>
          </label>
          <input type="submit" value="提交" />
        </form>
      </div>
    )
  }
  handleSubmit(event) {
    event.preventDefault();
    console.log(this.usernameRef.current.value);

  }
}
